/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author PhamLuc
 */
public class Check {

    public static boolean isNumber(String str) {
        try {
            Integer.valueOf(str);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
public static boolean isNumber1(String str) {
        try {
            Double.valueOf(str);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
    public static boolean isString(String str) {
        if (str.equals("")) {
            return false;
        } else {
            return true;
        }

    }
    
    /*
     * dua vao 1chuoi la email
     * neu hop le tra ve true email hop le 
     * else tra ve false email ko hop le
     */

    public static boolean Emailinvalid(String email) {
        Pattern pt3 = Pattern.compile("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$", Pattern.CASE_INSENSITIVE);
        Matcher mc1 = pt3.matcher(email);
        if (mc1.find()) {
            return true;
        } else {
            return false;
        }
    }

    public static boolean CheckName(int number) {
        if (number == 1) {
            return false;
        } else {
            return true;
        }
    }
    /*
     * 
     * 
     */
     public static boolean isValidEmail(String email)
    {
        if(email.matches("^[a-zA-Z]+((\\_|\\.)[a-zA-Z0-9]+)*\\@([a-zA-Z]+\\.)+[a-zA-Z]{2,4}$"))
            return true;
        return false;
    }
}
